package com.example.zhangpeng.scrollrecyclerview.view;

import android.content.Context;
import android.support.annotation.Nullable;
import android.support.v7.widget.RecyclerView;
import android.util.AttributeSet;
import android.view.MotionEvent;

/**
 * Created by zhangpeng on 2017/5/1.
 */

public class MyRecyclerView extends RecyclerView {
    private MyScrollView myScrollView;
    public MyRecyclerView(Context context) {
        super(context);
    }

    public MyRecyclerView(Context context, @Nullable AttributeSet attrs) {
        super(context, attrs);
    }

    public MyRecyclerView(Context context, @Nullable AttributeSet attrs, int defStyle) {
        super(context, attrs, defStyle);
    }

    public void setScrollView(MyScrollView myScrollView){
        this.myScrollView=myScrollView;
    }

    @Override
    public boolean onInterceptTouchEvent(MotionEvent e) {
        if(e.getAction()==MotionEvent.ACTION_MOVE){
           if (myScrollView.isScrolledToBottom()){
               return super.onInterceptTouchEvent(e);
           }else {
               return false;
           }
        }
        return super.onInterceptTouchEvent(e);
    }
}
